#ifndef UART_H
#define UART_H

#include <QObject>
#include <QDebug>
#include <termios.h>
class QSocketNotifier;

class Uart : public QObject
{
    Q_OBJECT

public:
    static Uart* getInstance();
    void init();
    void sendData(u_int8_t* buffer, int32_t length);

private:
    int32_t uartFd = -1;
    QSocketNotifier *readNotifier = nullptr;
    struct termios oldConfig;
    struct termios config;
    Uart():QObject{nullptr}{}
    void open();
    void readBytes(int fd, unsigned char *buf, int n);

private slots:
    void readDataSlot(int32_t);
};

#endif // MCUMODULE_H
